home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / casm / au116-as.exe / UTIL / DBAD.CPP < prev    next >
C/C++ Source or Header  |  1994-12-13  |  4KB  |  140 lines

  1. #include "..\au.hpp"
  2.  
  3. /*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
  4. static void dbad_printf(AU *au, char *format, ...)
  5. {
  6.     va_list plist;
  7.     char string[200];
  8.  
  9.     va_start(plist, format);
  10.     vsprintf(string, format, plist);
  11.     va_end(plist);
  12.  
  13.     au_printf_c(au, 12, "%s", string);
  14.  
  15. /*
  16.     if (!au->problem_handle.is_open() && au->problem_log[0] != '\0')
  17.     {
  18.         au->problem_handle.open(au, au->problem_log, O_CREAT|O_WRONLY|O_TEXT|O_APPEND);
  19.     }
  20.     au->problem_handle.write_raw(string, strlen(string));
  21. */
  22.     au->log.write(au, au->problem_log, string);
  23.     return;
  24. }
  25. /*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
  26. void add_to_bad_list(AU *au, char *path, char *file_name, BYTE errorlevel,
  27.                      int type)
  28. {
  29.     char string[FLENGTH];
  30.  
  31.     build_fname(string, path, file_name);
  32.     au->bad_list[type].add(string);
  33.     au->bad_count[type]++;
  34.  
  35.     au_printf(au, "\a");      /* bell sound */
  36.     switch (type)
  37.     {
  38.         case 0:
  39.             dbad_printf(au, "\nSuspicious Archive: '%s' Possibly Damaged\n", string);
  40.             break;
  41.         case 1:
  42.             dbad_printf(au, "\nDamaged Archive: '%s'\n", file_name);
  43.             break;
  44.         case 2:
  45.             dbad_printf(au, "\nInfected Archive: %s\n", file_name);
  46.             break;
  47.         case 3:
  48.             dbad_printf(au, "  Future Dated  ");
  49.             break;
  50.         case 4:
  51.             dbad_printf(au, "\nVirus checker was unable to process: %s\n", file_name);
  52.             break;
  53.         case 5:
  54.             dbad_printf(au, "\nFile is password encrypted, unable to process: %s\n", file_name);
  55.             break;
  56.     }
  57.     if (errorlevel > 0)
  58.         dbad_printf(au, "   (Errorlevel = %d)\n", errorlevel);
  59.  
  60.     press_any_key(au);       //FIXIT, seems like we almost need levels here
  61.  
  62. }
  63. /*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
  64. static void retest_suspicious(AU *au)
  65. {
  66.     LIST *el;
  67.     char hold_dir[FLENGTH];
  68.     char name[FILE_SIZE];
  69.     char path[FLENGTH];
  70.  
  71.     if (au->bad_list[0].head != NULL)
  72.         dbad_printf(au, "\nTesting Suspicious Archives\n");
  73.  
  74.     for (el = au->bad_list[0].head; el != NULL; el = el->next)
  75.     {
  76.         split_file(el->data, path, name);
  77.         cd(au, path, hold_dir);
  78.         if (test(au, name) < 0)
  79.         {
  80.             el->data[0] = '\0';
  81.             au->bad_count[0]--;
  82.         }
  83.         cd(au, hold_dir);
  84.     }
  85.     return;
  86. }
  87. /*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
  88. int display_bad_arcs(AU *au)
  89. {
  90.     LIST *el;
  91.     int  any=FALSE;
  92.  
  93.     if (au->retest == ON)
  94.         retest_suspicious(au);
  95.  
  96.     for (int i=0; i < MAX_ERRORS; i++)
  97.     {
  98.         if (au->bad_count[i] > 0)
  99.         {
  100.             any = TRUE;
  101.             switch (i)
  102.             {
  103.                 case 0:
  104.                     if (au->retest == ON)
  105.                         dbad_printf(au, "\nFiles AU had trouble with (please report) = %d\n",
  106.                                 au->bad_count[i]);
  107.                     else
  108.                         dbad_printf(au, "\nSuspicious Archives (Possibly Damaged) = %d\n",
  109.                                 au->bad_count[i]);
  110.                     break;
  111.                 case 1:
  112.                     dbad_printf(au, "\nDamaged Archives = %d\n", au->bad_count[i]);
  113.                     break;
  114.                 case 2:
  115.                     dbad_printf(au, "VIRUS(es) DETECTED!!!!\n");
  116.                     dbad_printf(au, "\nInfected Archives = %d\n", au->bad_count[i]);
  117.                     break;
  118.                 case 3:
  119.                     dbad_printf(au, "Future Dated Files = %d\n", au->bad_count[i]);
  120.                     break;
  121.                 case 4:
  122.                     dbad_printf(au, "Files the virus checker couldn't handle = %d\n", au->bad_count[i]);
  123.                     break;
  124.                 case 5:
  125.                     dbad_printf(au, "Files that are password encrypted = %d\n", au->bad_count[i]);
  126.                     break;
  127.             }
  128.             dbad_printf(au, "----------------------------------\n");
  129.             for (el = au->bad_list[i].head; el != NULL; el = el->next)
  130.             {
  131.                 if (el->data[0] != '\0')
  132.                     dbad_printf(au, "%s\n", el->data);
  133.             }
  134.             dbad_printf(au, "----------------------------------\n");
  135.             press_any_key(au);
  136.         }
  137.     }
  138.     return any;
  139. }
  140.